<?php
/**
 * recent.phtml
 * 
 * @category    Madoqua
 * @package     Module
 * @subpackage  BlogAdmin
 */
?>
<div class="recent-posts">
    <?php $count = count($this->posts); ?>
    <?php if ($count > 0) : ?>
    
    <ul class="col1">
        <?php for($x = 0; $x < $count / 2; $x++) : ?>
        <?php $post = $this->posts->current(); $this->posts->next(); ?>
        <?php if($post) : ?>
        <li>
            <h3>
                <a href="<?php echo $this->url(array('controller' => 'post', 'action' => 'update', 'id' => $post->id), 'blog_admin', true); ?>">
                    <?php echo $post->title; ?>
                </a>
            </h3>
            <a href="<?php echo $this->url(array('controller' => 'post', 'action' => 'update', 'id' => $post->id), 'blog_admin', true); ?>">
                <span class="date">
                  <?php echo $this->date($post->posted); ?>
                </span>
            </a>
        </li>
        <?php endif; ?>
        <?php endfor; ?>
    </ul>
    
    <ul class="col2">
        <?php for($x = (floor($count / 2)); $x < $count; $x++) : ?>
        <?php $post = $this->posts->current(); $this->posts->next();  ?>
        <?php if($post) : ?>
        <li>
            <h3>
                <a href="<?php echo $this->url(array('controller' => 'post', 'action' => 'update', 'id' => $post->id), 'blog_admin', true); ?>">
                    <?php echo $post->title; ?>
                </a>
            </h3>
            <a href="<?php echo $this->url(array('controller' => 'post', 'action' => 'update', 'id' => $post->id), 'blog_admin', true); ?>">
                <span class="date">
                  <?php echo $this->date($post->posted); ?>
                </span>
            </a>
        </li>
        <?php endif; ?>
        <?php endfor; ?>
    </ul>
    
    
    <?php else : ?>
    <p>
        You have not created any posts yet. Why don't you 
        <a href="<?php echo $this->url(array('action' => 'create', 'controller' => 'post'), 'blog_admin'); ?>">write</a> one!
    </p>
    
    <?php endif; ?>
</div>